var mapIds = [924030002, 924030300, 924030400, 924030500];
var 准备地图 = 240091500;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("岩壁巨人_升降突破");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    return c
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0))
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(a, b) {
    if (b == 9307008 || b == 9307010) {
        if (a.getNumberProperty("fail") == 0) {
            a.setProperty("fail", 1);
            player.getAPI().fieldEffect_ScreenMsg("killing/fail");
            player.scheduleWarpTask(3, 240091500, 2)
        }
    } else {
        if (player.getMap().getNumMonsters() == player.getMap().countMonsterById(9307008, 9307010)) {
            player.getAPI().updateInfoQuest(31359, "mission=success");
            player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
            player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
            player.getAPI().updateInfoQuest(31359, "");
            switch (player.getMapId()) {
                case 924030300:
                    player.scheduleWarpTask(3, 924030400, 0, false);
                    break;
                case 924030400:
                    player.scheduleWarpTask(3, 924030500, 0, false);
                    break;
                case 924030500:
                    player.scheduleWarpTask(3, 924030004, 0, false);
                    break
            }
        }
    }
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    b.getAPI().onClearGun();
    b.getAPI().enableActions();
    b.getAPI().setInGameDirectionMode(false, false, false);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};